<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */


use app\controller\Api\V1\Client\AnnouncementController;
use app\controller\Api\V1\Client\Auth\AccountController;
use app\controller\Api\V1\Client\Auth\ChannelSdkController;
use app\controller\Api\V1\Client\ConfigController;
use app\controller\Api\V1\Client\EnrollController;
use app\controller\Api\V1\Client\GiftBagController;
use app\controller\Api\V1\Client\InfoController;
use app\controller\Api\V1\Client\InitController;
use app\controller\Api\V1\Client\KitVersionController;
use app\controller\Api\V1\Client\Lander\ListController;
use app\controller\Api\V1\Client\MultipleVersionController;
use app\controller\Api\V1\Client\OfficialResourcesController;
use app\controller\Api\V1\Client\RechargeController;
use app\controller\Api\V1\Client\ResourcesController;
use app\controller\Api\V1\Client\SellController;
use app\controller\Api\V1\Client\VersionController;
use app\controller\Api\V1\Client\VoiceChatController;
use app\controller\Api\V1\Client\WebsocketController;
use app\controller\Api\V1\Client\Common\IpController;
use app\middleware\SellTokenAuth;
use app\middleware\SignAuth;
use app\middleware\TokenAuth;
use Webman\Route;

Route::get('/api/v1/client/lander/list-xuteng', [ListController::class, 'listXuTeng']);  //xuTeng 栩腾  区服列表
Route::get('/api/v1/client/common/ip', [IpController::class, 'getClientIp']); //获取请求IP



Route::group('/api', function () {
    Route::group('/v1', function () {
        Route::group('/client', function () {
            // 初始化
            Route::post('/init', [InitController::class, 'Init']);
            Route::post('/init-v2', [InitController::class, 'InitV2']);
            // RocketMQ初始化
            Route::post('/init-rocket-mq', [InitController::class, 'InitRocketMQ']);
            // 版本初始化
            Route::post('/init-version', [InitController::class, 'InitVersion']);
            // 引擎初始化
            Route::post('/init-engine', [InitController::class, 'InitEngine']);
            // 配置初始化
            Route::post('/init-config', [InitController::class, 'InitConfig']);
            // 客户端授权登记
            Route::post('/enroll', [EnrollController::class, 'Enroll']);
            // 认证
            Route::group('/auth', function () {
                Route::post('/register', [AccountController::class, 'Register']);  // 注册
                Route::post('/login', [AccountController::class, 'Login']);  // 登录
                Route::post('/phone-login', [AccountController::class, 'PhoneLogin']);  // 手机登录
                Route::post('/refresh-auth', [AccountController::class, 'RefreshAuth']);  // 手机登录
                Route::post('/get-info', [AccountController::class, 'GetInfo']);  // 通过token获取用户信息
                Route::post('/reset-password', [AccountController::class, 'ResetPassword']);  // 重置密码
                Route::post('/reset-secret-protection', [AccountController::class, 'ResetSecretProtection']);  // 重置密保
                Route::post('/real-name-submit', [AccountController::class, 'RealNameSubmit']);  // 实名认证
                Route::post('/bind-phone', [AccountController::class, 'BindPhone']);  // 绑定手机
                Route::post('/modify-phone', [AccountController::class, 'ModifyPhone']);  // 修改手机

                Route::group('/sdk', function () {
                    Route::post('/auth', [ChannelSdkController::class, 'Auth']);
                });
            });

            // 登录器
            Route::group('/lander', function () {
                Route::post("/list", [ListController::class, "List"]);  // 获取区服列表
            });
            // 版本
            Route::group('/version', function () {
                Route::post('/download', [VersionController::class, 'Download']);
            });
            // 多版本
            Route::group('/multiple-version', function () {
                Route::post('/list', [MultipleVersionController::class, 'List']);
            });
            // 资源
            Route::group('/resources', function () {
                Route::post('/download', [ResourcesController::class, 'Download']);
            });
            // 信息
            Route::group('/info', function () {
                Route::post('/get-info', [InfoController::class, 'GetInfo']);
            });
            // 公告
            Route::group('/announcement', function () {
                Route::post('/login', [AnnouncementController::class, 'Login']);
            });

            // 资源
            Route::group('/official-resources', function () {
                Route::post('/download', [OfficialResourcesController::class, 'Download']);
            });

            // 配套工具版本
            Route::group('/kit-version', function () {
                Route::post('/download', [KitVersionController::class, 'Download']);
            });

            // 充值
            Route::group('/recharge', function () {
                Route::post('/config', [RechargeController::class, 'Config']);
            });

            // 配置
            Route::group('/config', function () {
                Route::post('/generate', [ConfigController::class, 'Generate']);
                Route::post('/log', [ConfigController::class, 'Log']);
            });


            // 交易行
            Route::group('/sell', function () {
                Route::post('/init', [SellController::class, 'Init']);
                Route::post('/sms-verify', [SellController::class, 'SmsVerify']);
                Route::post('/list', [SellController::class, 'List']);
                Route::post('/record', [SellController::class, 'Record']);
                Route::post('/dicker', [SellController::class, 'Dicker']);
                Route::post('/buy', [SellController::class, 'Buy']);
                Route::post('/retrieve-role-verify', [SellController::class, 'RetrieveRoleVerify']);
                Route::post('/receive-role-verify', [SellController::class, 'ReceiveRoleVerify']);
                Route::post('/return-role-verify', [SellController::class, 'ReturnRoleVerify']);

                Route::group('', function () {
                    Route::post('/sell-role', [SellController::class, 'SellRole']);
                    Route::post('/sell-role-result', [SellController::class, 'SellRoleResult']);
                    Route::post('/retrieve-role', [SellController::class, 'RetrieveRole']);
                    Route::post('/retrieve-role-result', [SellController::class, 'RetrieveRoleResult']);
                    Route::post('/receive-role', [SellController::class, 'ReceiveRole']);
                    Route::post('/return-role', [SellController::class, 'ReturnRole']);
                })->middleware([
                    SellTokenAuth::class
                ]);
            })->middleware([
                TokenAuth::class,
            ]);

            // 礼包
            Route::group('/gift', function () {
                Route::post('/init', [GiftBagController::class, 'Init']);
                Route::post('/exchange', [GiftBagController::class, 'Exchange']);
                Route::post('/exchange-gift-list', [GiftBagController::class, 'ExchangeGiftList']);
            })->middleware([
                TokenAuth::class,
            ]);

            // Websocket
            Route::group('/websocket', function () {
                Route::post('/init', [WebsocketController::class, 'Init']);
            });

            // 语音聊天
            Route::group('/voice-chat', function () {
                Route::post('/init', [VoiceChatController::class, 'Init']);
            })->middleware([
                TokenAuth::class,
            ]);
        });
    });
})->middleware([
    SignAuth::class
]);


Route::disableDefaultRoute();
